home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Pascal Super Library
/
Pascal Super Library (CW International)(1997).bin
/
LIBRARY
/
FUTILS
/
FSWAP.DOC
< prev
next >
Wrap
Text File
|
1989-02-19
|
2KB
|
63 lines
/\ RKCP /\
\/ RKCP \/
********************************************************************
************************* FSWAP by Rex Kerr ************************
************************ Copyright (C) 1989 ************************
********************************************************************
This is a tiny unit for Turbo Pascal 5.0, written in assembly
language. Since it is written in assembler, it is both very small
and very fast.
There are just 3 procedures in this unit.
***
QSwapB(var a,b : byte);
This swaps two bytes.
***
QSwapW(var a,b : word);
This swaps two words.
***
QSwapV(var a,b; len : word);
This swaps the first len bytes of a and b.
***
That's it. No more messy procedures like this:
procedure SwapW(var a,b : word);
var temp : word;
begin
temp := a;
a := b;
b := temp
end;
The three QSwaps are better that pascal things like this on two
counts:
1) They are faster (about 50% faster with words).
2) They save stack space, as no temp is needed.
Now, it is true that with large records and arrays ( > 50 bytes)
a pascal procedure that declares an entire one of the record or
array is faster. But is is very stack hungry! Do your own
benchmarks (if have stack space to spare, and really need the
speed).
If I've left anything out, or if something isn't clear, please
contact me via the TP5 Messages section of BPROGA or EasyPlex
on CompuServe.
Rex Kerr 71550,3147
/\ RKCP /\
\/ RKCP \/